package com.pr.makfilm.domain;

import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created by parado on 11.03.14.
 */
@Entity
@Table(name = "reservation")
public class Reservation extends IdentifiableEntity
{
   public static final String FIELD_SCHOOL = "school";

   public static final String FIELD_EVENT = "event";

   public static final String FIELD_CONTACT_PERSON = "contactPerson";

   public static final String FIELD_PAID_PLACE_AMOUNT = "paidPlaceAmount";

   public static final String FIELD_FREE_PLACE_AMOUNT = "freePlaceAmount";

   public static final String FIELD_CREATION_DATE = "creationDate";

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private School school;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private Event event;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(name = "contact_person", nullable = false)
   @NotNull
   private ContactPerson contactPerson;

   @Column(name = "paid_place_amount", nullable = false)
   @NotNull
   private int paidPlaceAmount = 0;

   @Column(name = "free_place_amount", nullable = false)
   @NotNull
   private int freePlaceAmount = 0;

   @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
   @Column(name = "creation_date", nullable = false)
   @NotNull
   private DateTime creationDate;

   public DateTime getCreationDate()
   {
      return creationDate;
   }

   public void setCreationDate(DateTime creationDate)
   {
      this.creationDate = creationDate;
   }

   public School getSchool()
   {
      return school;
   }

   public void setSchool(School school)
   {
      this.school = school;
   }

   public Event getEvent()
   {
      return event;
   }

   public void setEvent(Event event)
   {
      this.event = event;
   }

   public ContactPerson getContactPerson()
   {
      return contactPerson;
   }

   public void setContactPerson(ContactPerson contactPerson)
   {
      this.contactPerson = contactPerson;
   }

   public int getPaidPlaceAmount()
   {
      return paidPlaceAmount;
   }

   public void setPaidPlaceAmount(int paidPlaceAmount)
   {
      this.paidPlaceAmount = paidPlaceAmount;
   }

   public int getFreePlaceAmount()
   {
      return freePlaceAmount;
   }

   public void setFreePlaceAmount(int freePlaceAmount)
   {
      this.freePlaceAmount = freePlaceAmount;
   }

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }
}
